import { request } from '@umijs/max';
import { IRes } from '.';

export interface IAuth {
  isLogin: boolean;
  loginDevice: string;
  loginId: string;
  loginType: 'login';
  sessionTimeout: number;
  tokenActivityTimeout: number;
  tokenName: string;
  tokenSessionTimeout: number;
  tokenTimeout: number;
  tokenValue: string;
  token: string;
}

export enum EApplication {
  application = 'pc',
}

export async function apiAccountLogin(data: {
  username: string;
  password: string;
}) {
  return request<{ code: number; msg: string; data: IAuth }>(
    '/v1/business/auth/login',
    {
      method: 'POST',
      data,
    },
  );
}

export async function apiAccountLoginOut(params: { userId?: number }) {
  return request<IRes<boolean>>(`/v1/account/logOut`, {
    method: 'Get',
    params,
  });
}
